package com.eascs.workflow.util;

import java.util.Date;

import com.eascs.admin.o2o.credit.entity.CreditReport;
import com.eascs.admin.o2o.internal.util.StatusContexts;
import com.eascs.workflow.form.CreditForm;

/**
 * 征信表单转换类
 * 
 * @author ycz
 *
 */
public class CreditTransforCreditFrom {
	/**
	 * @param creditForm
	 * @param creditReport
	 * @param materCreditReport
	 * @return
	 */
	public final static CreditForm CreditTransToForm(CreditForm creditForm, CreditReport creditReport,
			CreditReport materCreditReport) {
		Double spouseContract;
		Double spouseBalance;
		Double spouseAssure;
		Double spouseOverdue;
		Double outAssureOverdue;
		creditForm.setId(creditReport.getId());
		creditForm.setParentId(creditReport.getParentId());
		creditForm.setAssureBalance(creditReport.getAssureBalance());
		creditForm.setAssureStatus(creditReport.getAssureStatus());
		creditForm.setAssureTotal(creditReport.getAssureTotal());
		creditForm.setAvgCardusedAmt(creditReport.getAvgCardusedAmt());
		creditForm.setPaymentBalance(creditReport.getPaymentBalance());
		creditForm.setContractTotal(creditReport.getContractTotal());
		creditForm.setContractTotalOverdue(creditReport.getContractTotalOverdue());
		creditForm.setOutAssureBalance(creditReport.getOutAssureBalance());
		creditForm.setBankPaymentBalance(creditReport.getBankPaymentBalance());
		creditForm.setMortgageHouse(creditReport.getMortgageHouse());
		creditForm.setMortgageHouseBalance(creditReport.getMortgageHouseBalance());
		creditForm.setAvgmonthRepayHouse(creditReport.getAvgmonthRepayHouse());
		creditForm.setMortgageCar(creditReport.getMortgageCar());
		creditForm.setRemark(creditReport.getRemark());
		creditForm.setMortgageCarBalance(creditReport.getMortgageCarBalance());
		creditForm.setAvgmonthRepayCar(creditReport.getAvgmonthRepayCar());
		creditForm.setCreditPaymentBalance(creditReport.getCreditPaymentBalance());
		creditForm.setPledgePaymentBalance(creditReport.getPledgePaymentBalance());
		creditForm.setImpawnPaymentBalance(creditReport.getImpawnPaymentBalance());
		creditForm.setGroupAssureBalance(creditReport.getGroupAssureBalance());
		creditForm.setNonbankPaymentBalance(creditReport.getNonbankPaymentBalance());
		creditForm.setCreditCount(creditReport.getCreditCount());
		creditForm.setCreditBalance(creditReport.getCreditBalance());
		creditForm.setCreditLimitRate(creditReport.getCreditLimitRate());
		creditForm.setOutAssureCount(creditReport.getOutAssureCount());
		creditForm.setCreditSearch(creditReport.getCreditSearch());
		creditForm.setPaymentStatus(creditReport.getPaymentStatus());
		creditForm.setCreditStatus(creditReport.getCreditStatus());
		creditForm.setCourtEnforcementStatus(creditReport.getCourtEnforcementStatus());
		creditForm.setPaymentOverdueStatus(creditReport.getPaymentOverdueStatus());
		creditForm.setCreditOverdueStatus(creditReport.getCreditOverdueStatus());
		creditForm.setPaymentYearStatus(creditReport.getPaymentYearStatus());
		creditForm.setNonbankBalanceOverdue(creditReport.getNonbankBalanceOverdue());
		creditForm.setOutAssureBalanceOverdue(creditReport.getOutAssureBalanceOverdue());
		creditForm.setBankBalanceOverdue(creditReport.getBankBalanceOverdue());
		creditForm.setCreditLimitOverdue(creditReport.getCreditLimitOverdue());
		creditForm.setSixOverBalance(null ==creditReport.getSixOverBalance() ? 0d:creditReport.getSixOverBalance());
		creditForm.setTwentyFourOverdueCount(null==creditReport.getTwentyFourOverdueCount()? 0:creditReport.getTwentyFourOverdueCount());
		creditForm.setTwentyFourOverdueCreditCount(null==creditReport.getTwentyFourOverdueCreditCount()? 0:creditReport.getTwentyFourOverdueCreditCount());
		creditForm.setTwentyFourOverdueTopCount(null==creditReport.getTwentyFourOverdueTopCount()? 0:creditReport.getTwentyFourOverdueTopCount());
		creditForm.setTwentyFourOverdueCreditTopCount(null==creditReport.getTwentyFourOverdueCreditTopCount()? 0:creditReport.getTwentyFourOverdueCreditTopCount());
		spouseContract = null == creditReport.getContractTotal() ? 0d : creditReport.getContractTotal();
		spouseAssure = null == creditReport.getOutAssureBalance() ? 0d : creditReport.getOutAssureBalance();
		spouseBalance = null == creditReport.getPaymentBalance() ? 0d : creditReport.getPaymentBalance();
		spouseOverdue=null==creditReport.getContractTotalOverdue()?0d:creditReport.getContractTotalOverdue();
		outAssureOverdue=null==creditReport.getOutAssureBalanceOverdue()?0d:creditReport.getOutAssureBalanceOverdue();
		if (null != materCreditReport) {
			creditForm.setAssureBalance1(materCreditReport.getAssureBalance());
			creditForm.setAssureStatus1(materCreditReport.getAssureStatus());
			creditForm.setAssureTotal1(materCreditReport.getAssureTotal());
			creditForm.setAvgCardusedAmt1(materCreditReport.getAvgCardusedAmt());
			creditForm.setPaymentBalance1(materCreditReport.getPaymentBalance());
			creditForm.setContractTotal1(materCreditReport.getContractTotal());
			creditForm.setContractTotalOverdue1(materCreditReport.getContractTotalOverdue());
			creditForm.setOutAssureBalance1(materCreditReport.getOutAssureBalance());
			creditForm.setBankPaymentBalance1(materCreditReport.getBankPaymentBalance());
			creditForm.setMortgageHouse1(materCreditReport.getMortgageHouse());
			creditForm.setMortgageHouseBalance1(materCreditReport.getMortgageHouseBalance());
			creditForm.setAvgmonthRepayHouse1(materCreditReport.getAvgmonthRepayHouse());
			creditForm.setMortgageCar1(materCreditReport.getMortgageCar());
			creditForm.setMortgageCarBalance1(materCreditReport.getMortgageCarBalance());
			creditForm.setAvgmonthRepayCar1(materCreditReport.getAvgmonthRepayCar());
			creditForm.setCreditPaymentBalance1(materCreditReport.getCreditPaymentBalance());
			creditForm.setPledgePaymentBalance1(materCreditReport.getPledgePaymentBalance());
			creditForm.setImpawnPaymentBalance1(materCreditReport.getImpawnPaymentBalance());
			creditForm.setGroupAssureBalance1(materCreditReport.getGroupAssureBalance());
			creditForm.setNonbankPaymentBalance1(materCreditReport.getNonbankPaymentBalance());
			creditForm.setCreditCount1(materCreditReport.getCreditCount());
			creditForm.setRemark1(creditReport.getRemark());
			creditForm.setCreditBalance1(materCreditReport.getCreditBalance());
			creditForm.setCreditLimitRate1(materCreditReport.getCreditLimitRate());
			creditForm.setOutAssureCount1(materCreditReport.getOutAssureCount());
			creditForm.setCreditSearch1(materCreditReport.getCreditSearch());
			creditForm.setPaymentStatus1(materCreditReport.getPaymentStatus());
			creditForm.setCreditStatus1(materCreditReport.getCreditStatus());
			creditForm.setCourtEnforcementStatus1(materCreditReport.getCourtEnforcementStatus());
			creditForm.setPaymentOverdueStatus1(materCreditReport.getPaymentOverdueStatus());
			creditForm.setCreditOverdueStatus1(materCreditReport.getCreditOverdueStatus());
			creditForm.setPaymentYearStatus1(materCreditReport.getPaymentYearStatus());
			creditForm.setRemark1(materCreditReport.getRemark());
			creditForm.setNonbankBalanceOverdue1(materCreditReport.getNonbankBalanceOverdue());
			creditForm.setOutAssureBalanceOverdue1(materCreditReport.getOutAssureBalanceOverdue());
			creditForm.setBankBalanceOverdue1(materCreditReport.getBankBalanceOverdue());
			creditForm.setCreditLimitOverdue1(materCreditReport.getCreditLimitOverdue());
			creditForm.setSixOverBalance1(null ==materCreditReport.getSixOverBalance() ? 0d:materCreditReport.getSixOverBalance());
			creditForm.setTwentyFourOverdueCount1(null==materCreditReport.getTwentyFourOverdueCount()? 0:materCreditReport.getTwentyFourOverdueCount());
			creditForm.setTwentyFourOverdueCreditCount1(null==materCreditReport.getTwentyFourOverdueCreditCount()? 0:materCreditReport.getTwentyFourOverdueCreditCount());
			creditForm.setTwentyFourOverdueTopCount1(null==materCreditReport.getTwentyFourOverdueTopCount()? 0:materCreditReport.getTwentyFourOverdueTopCount());
			creditForm.setTwentyFourOverdueCreditTopCount1(null==materCreditReport.getTwentyFourOverdueCreditTopCount()? 0:materCreditReport.getTwentyFourOverdueCreditTopCount());
			if (materCreditReport.getContractTotal() != null) {
				spouseContract = spouseContract + materCreditReport.getContractTotal();
			}
			if (materCreditReport.getPaymentBalance() != null) {
				spouseBalance = spouseBalance + materCreditReport.getPaymentBalance();
			}
			if (materCreditReport.getOutAssureBalance() != null) {
				spouseAssure = spouseAssure + materCreditReport.getOutAssureBalance();
			}
			if(materCreditReport.getContractTotalOverdue()!=null){
				spouseOverdue=spouseOverdue+materCreditReport.getContractTotalOverdue();
			}
			if(materCreditReport.getOutAssureBalanceOverdue()!=null){
				outAssureOverdue=outAssureOverdue+materCreditReport.getOutAssureBalanceOverdue();
			}
		}
		
		creditForm.setSpouseContractTotal(spouseContract);
		creditForm.setSpouseBalanceTotal(spouseBalance);
		creditForm.setSpouseAssureTotal(spouseAssure);
		creditForm.setSpouseOverdue(spouseOverdue);
		creditForm.setOutAssureOverdue(outAssureOverdue);
		return creditForm;
	}

	/**
	 * 主贷款转换实体
	 * 
	 * @param creditReport
	 * @param creditForm
	 */
	public static void saveCreditReport(CreditReport creditReport, CreditForm creditForm) {
		Date date = new Date();
		// 银行贷款总额
		Double bankPaymentBalance = (null == creditForm.getMortgageCarBalance() ? 0d
				: creditForm.getMortgageCarBalance())
				+ (null == creditForm.getPledgePaymentBalance() ? 0d : creditForm.getPledgePaymentBalance())
				+ (null == creditForm.getImpawnPaymentBalance() ? 0d : creditForm.getImpawnPaymentBalance())
				+ (null == creditForm.getGroupAssureBalance() ? 0d : creditForm.getGroupAssureBalance())
				+ (null == creditForm.getMortgageHouseBalance() ? 0d : creditForm.getMortgageHouseBalance())
				+ (null == creditForm.getCreditPaymentBalance() ? 0d : creditForm.getCreditPaymentBalance());
		// 对外担保总余额
		creditReport.setOutAssureBalance(null==creditForm.getAssureBalance()?0d:creditForm.getAssureBalance());
		Double paymentBalance = bankPaymentBalance
				+ (null == creditForm.getNonbankPaymentBalance() ? 0d : creditForm.getNonbankPaymentBalance())
				+ (null == creditForm.getCreditLimitRate() ? 0d : creditForm.getCreditLimitRate());
		creditReport.setPaymentBalance(paymentBalance + (null ==creditForm.getAssureBalance() ? 0d :creditForm.getAssureBalance()/2));//贷款余额需要加上担保余额的50%， 工单：loan-12621
		creditReport.setBankPaymentBalance(bankPaymentBalance);
		creditReport.setBankBalanceOverdue(null==creditForm.getBankBalanceOverdue()?0d:creditForm.getBankBalanceOverdue());
		creditReport.setNonbankBalanceOverdue(null==creditForm.getNonbankBalanceOverdue()?0d:creditForm.getNonbankBalanceOverdue());
		creditReport.setOutAssureBalanceOverdue(null==creditForm.getOutAssureBalanceOverdue()?0d:creditForm.getOutAssureBalanceOverdue());
		creditReport.setCreditLimitOverdue(null==creditForm.getCreditLimitOverdue()?0d:creditForm.getCreditLimitOverdue());
		creditReport.setAssureBalance(null ==creditForm.getAssureBalance() ? 0d :creditForm.getAssureBalance());
		creditReport.setAssureStatus(creditForm.getAssureStatus());
		creditReport.setAssureTotal(null ==creditForm.getAssureTotal() ? 0d :creditForm.getAssureTotal());
		creditReport.setAvgCardusedAmt(null ==creditForm.getAvgCardusedAmt() ? 0d :creditForm.getAvgCardusedAmt() );
		creditReport.setContractTotal((null ==creditForm.getContractTotal() ? 0d :creditForm.getContractTotal()) + (null ==creditForm.getAssureTotal() ? 0d :creditForm.getAssureTotal()/2));//贷款余额需要加上担保余额的50% 工单：loan-12621
		creditReport.setContractTotalOverdue(creditReport.getCreditLimitOverdue()+creditReport.getNonbankBalanceOverdue()+creditReport.getBankBalanceOverdue());
		creditReport.setMortgageHouse(null ==creditForm.getMortgageHouse() ? 0 :creditForm.getMortgageHouse());
		creditReport.setMortgageHouseBalance(null ==creditForm.getMortgageHouseBalance() ? 0d :creditForm.getMortgageHouseBalance());
		creditReport.setAvgmonthRepayHouse(null ==creditForm.getAvgmonthRepayHouse() ? 0d :creditForm.getAvgmonthRepayHouse());
		creditReport.setMortgageCar(null ==creditForm.getMortgageCar() ? 0 :creditForm.getMortgageCar());
		creditReport.setMortgageCarBalance(null ==creditForm.getMortgageCarBalance() ? 0d :creditForm.getMortgageCarBalance());
		creditReport.setAvgmonthRepayCar(null ==creditForm.getAvgmonthRepayCar() ? 0d :creditForm.getAvgmonthRepayCar());
		creditReport.setCreditPaymentBalance(null ==creditForm.getCreditPaymentBalance() ? 0d :creditForm.getCreditPaymentBalance());
		creditReport.setPledgePaymentBalance(null ==creditForm.getPledgePaymentBalance() ? 0d :creditForm.getPledgePaymentBalance() );
		creditReport.setImpawnPaymentBalance(null ==creditForm.getImpawnPaymentBalance() ? 0d :creditForm.getImpawnPaymentBalance());
		creditReport.setGroupAssureBalance(null ==creditForm.getGroupAssureBalance() ? 0d :creditForm.getGroupAssureBalance());
		creditReport.setCreditCount(null ==creditForm.getCreditCount() ? 0 :creditForm.getCreditCount());
		creditReport.setCreditBalance(null ==creditForm.getCreditBalance() ? 0d :creditForm.getCreditBalance());
		creditReport.setCreditLimitRate(null ==creditForm.getCreditLimitRate() ? 0d :creditForm.getCreditLimitRate());
		creditReport.setOutAssureCount(null ==creditForm.getOutAssureCount() ? 0 :creditForm.getOutAssureCount());
		creditReport.setCreditSearch(null ==creditForm.getCreditSearch() ? 0 :creditForm.getCreditSearch());
		creditReport.setPaymentStatus(creditForm.getPaymentStatus());
		creditReport.setCreditStatus(creditForm.getCreditStatus());
		creditReport.setCourtEnforcementStatus(creditForm.getCourtEnforcementStatus());
		creditReport.setPaymentOverdueStatus(creditForm.getPaymentOverdueStatus());
		creditReport.setCreditOverdueStatus(creditForm.getCreditOverdueStatus());
		creditReport.setPaymentYearStatus(creditForm.getPaymentYearStatus());
		creditReport.setNonbankPaymentBalance(null ==creditForm.getNonbankPaymentBalance() ? 0d :creditForm.getNonbankPaymentBalance());
		creditReport.setSixOverBalance(null ==creditForm.getSixOverBalance() ? 0d:creditForm.getSixOverBalance());
		creditReport.setTwentyFourOverdueCount(null==creditForm.getTwentyFourOverdueCount()? 0:creditForm.getTwentyFourOverdueCount());
		creditReport.setTwentyFourOverdueCreditCount(null==creditForm.getTwentyFourOverdueCreditCount()? 0:creditForm.getTwentyFourOverdueCreditCount());
		creditReport.setTwentyFourOverdueTopCount(null==creditForm.getTwentyFourOverdueTopCount()? 0:creditForm.getTwentyFourOverdueTopCount());
		creditReport.setTwentyFourOverdueCreditTopCount(null==creditForm.getTwentyFourOverdueCreditTopCount()? 0:creditForm.getTwentyFourOverdueCreditTopCount());
		creditReport.setRemark(creditForm.getRemark());
		creditReport.setLoanapplyNo(creditForm.getLoanapplyNo());
		creditReport.setParentId(String.valueOf(StatusContexts.O2O_ZERO));
		creditReport.setCreateTime(date);
		creditReport.setUpdateTime(date);
		creditReport.setFlag(StatusContexts.O2O_YES);
	}

	/**
	 * 主贷款转换实体 修改
	 * 
	 * @param creditReport
	 * @param creditForm
	 */
	public static void updateCreditReport(CreditReport creditReport, CreditForm creditForm) {
		// 银行贷款总额
		Double bankPaymentBalance = (null == creditForm.getMortgageCarBalance() ? 0d
				: creditForm.getMortgageCarBalance())
				+ (null == creditForm.getMortgageHouseBalance() ? 0d : creditForm.getMortgageHouseBalance())
				+ (null == creditForm.getPledgePaymentBalance() ? 0d : creditForm.getPledgePaymentBalance())
				+ (null == creditForm.getImpawnPaymentBalance() ? 0d : creditForm.getImpawnPaymentBalance())
				+ (null == creditForm.getGroupAssureBalance() ? 0d : creditForm.getGroupAssureBalance())
				+ (null == creditForm.getCreditPaymentBalance() ? 0d : creditForm.getCreditPaymentBalance());
		// 对外担保总余额
		creditReport.setOutAssureBalance(null ==creditForm.getAssureBalance()?0d:creditForm.getAssureBalance());
		Double paymentBalance = bankPaymentBalance
				+ (null == creditForm.getNonbankPaymentBalance() ? 0d : creditForm.getNonbankPaymentBalance())
				+ (null == creditForm.getCreditLimitRate() ? 0d : creditForm.getCreditLimitRate());
		creditReport.setPaymentBalance(paymentBalance);
		creditReport.setBankPaymentBalance(bankPaymentBalance);
		creditReport.setBankBalanceOverdue(null==creditForm.getBankBalanceOverdue()?0d:creditForm.getBankBalanceOverdue());
		creditReport.setNonbankBalanceOverdue(null==creditForm.getNonbankBalanceOverdue()?0d:creditForm.getNonbankBalanceOverdue());
		creditReport.setOutAssureBalanceOverdue(null==creditForm.getOutAssureBalanceOverdue()?0d:creditForm.getOutAssureBalanceOverdue());
		creditReport.setCreditLimitOverdue(null==creditForm.getCreditLimitOverdue()?0d:creditForm.getCreditLimitOverdue());
		creditReport.setAssureBalance(null ==creditForm.getAssureBalance() ? 0d :creditForm.getAssureBalance());
		creditReport.setAssureStatus(creditForm.getAssureStatus());
		creditReport.setAssureTotal(null ==creditForm.getAssureTotal() ? 0d :creditForm.getAssureTotal());
		creditReport.setAvgCardusedAmt(null ==creditForm.getAvgCardusedAmt() ? 0d :creditForm.getAvgCardusedAmt() );
		creditReport.setContractTotal(null ==creditForm.getContractTotal() ? 0d :creditForm.getContractTotal());
		creditReport.setMortgageHouse(null ==creditForm.getMortgageHouse() ? 0 :creditForm.getMortgageHouse());
		creditReport.setMortgageHouseBalance(null ==creditForm.getMortgageHouseBalance() ? 0d :creditForm.getMortgageHouseBalance());
		creditReport.setAvgmonthRepayHouse(null ==creditForm.getAvgmonthRepayHouse() ? 0d :creditForm.getAvgmonthRepayHouse());
		creditReport.setMortgageCar(null ==creditForm.getMortgageCar() ? 0 :creditForm.getMortgageCar());
		creditReport.setMortgageCarBalance(null ==creditForm.getMortgageCarBalance() ? 0d :creditForm.getMortgageCarBalance());
		creditReport.setAvgmonthRepayCar(null ==creditForm.getAvgmonthRepayCar() ? 0d :creditForm.getAvgmonthRepayCar());
		creditReport.setCreditPaymentBalance(null ==creditForm.getCreditPaymentBalance() ? 0d :creditForm.getCreditPaymentBalance());
		creditReport.setPledgePaymentBalance(null ==creditForm.getPledgePaymentBalance() ? 0d :creditForm.getPledgePaymentBalance() );
		creditReport.setImpawnPaymentBalance(null ==creditForm.getImpawnPaymentBalance() ? 0d :creditForm.getImpawnPaymentBalance());
		creditReport.setGroupAssureBalance(null ==creditForm.getGroupAssureBalance() ? 0d :creditForm.getGroupAssureBalance());
		creditReport.setCreditCount(null ==creditForm.getCreditCount() ? 0 :creditForm.getCreditCount());
		creditReport.setCreditBalance(null ==creditForm.getCreditBalance() ? 0d :creditForm.getCreditBalance());
		creditReport.setCreditLimitRate(null ==creditForm.getCreditLimitRate() ? 0d :creditForm.getCreditLimitRate());
		creditReport.setOutAssureCount(null ==creditForm.getOutAssureCount() ? 0 :creditForm.getOutAssureCount());
		creditReport.setCreditSearch(null ==creditForm.getCreditSearch() ? 0 :creditForm.getCreditSearch());
		creditReport.setPaymentStatus(creditForm.getPaymentStatus());
		creditReport.setCreditStatus(creditForm.getCreditStatus());
		creditReport.setCourtEnforcementStatus(creditForm.getCourtEnforcementStatus());
		creditReport.setPaymentOverdueStatus(creditForm.getPaymentOverdueStatus());
		creditReport.setCreditOverdueStatus(creditForm.getCreditOverdueStatus());
		creditReport.setPaymentYearStatus(creditForm.getPaymentYearStatus());
		creditReport.setNonbankPaymentBalance(null ==creditForm.getNonbankPaymentBalance() ? 0d :creditForm.getNonbankPaymentBalance());
		creditReport.setSixOverBalance(null ==creditForm.getSixOverBalance() ? 0d:creditForm.getSixOverBalance());
		creditReport.setTwentyFourOverdueCount(null==creditForm.getTwentyFourOverdueCount()? 0:creditForm.getTwentyFourOverdueCount());
		creditReport.setTwentyFourOverdueCreditCount(null==creditForm.getTwentyFourOverdueCreditCount()? 0:creditForm.getTwentyFourOverdueCreditCount());
		creditReport.setTwentyFourOverdueTopCount(null==creditForm.getTwentyFourOverdueTopCount()? 0:creditForm.getTwentyFourOverdueTopCount());
		creditReport.setTwentyFourOverdueCreditTopCount(null==creditForm.getTwentyFourOverdueCreditTopCount()? 0:creditForm.getTwentyFourOverdueCreditTopCount());
		creditReport.setRemark(creditForm.getRemark());
		creditReport.setId(creditForm.getId());
		creditReport.setContractTotalOverdue(creditReport.getCreditLimitOverdue()+creditReport.getNonbankBalanceOverdue()+creditReport.getBankBalanceOverdue());
	}

	/**
	 * 配偶贷款 保存
	 * 
	 * @param creditReport
	 * @param creditForm
	 */
	public static void saveSpouseCreditReport(CreditReport creditReport, CreditForm creditForm) {
		Date date = new Date();
		creditReport.setAssureBalance(null ==creditForm.getAssureBalance1() ? 0d :creditForm.getAssureBalance1());
		creditReport.setAssureStatus(creditForm.getAssureStatus1());
		creditReport.setAssureTotal(null ==creditForm.getAssureTotal1() ? 0d :creditForm.getAssureTotal1());
		creditReport.setAvgCardusedAmt(null ==creditForm.getAvgCardusedAmt1() ? 0d :creditForm.getAvgCardusedAmt1() );
		creditReport.setContractTotal((null ==creditForm.getContractTotal1() ? 0d :creditForm.getContractTotal1())  + (null ==creditForm.getAssureTotal1() ? 0d :creditForm.getAssureTotal1()/2));//贷款余额需要加上担保余额的50% 工单：loan-12621
		creditReport.setMortgageHouse(null ==creditForm.getMortgageHouse1() ? 0 :creditForm.getMortgageHouse1());
		creditReport.setMortgageHouseBalance(null ==creditForm.getMortgageHouseBalance1() ? 0d :creditForm.getMortgageHouseBalance1());
		creditReport.setAvgmonthRepayHouse(null ==creditForm.getAvgmonthRepayHouse1() ? 0d :creditForm.getAvgmonthRepayHouse1());
		creditReport.setMortgageCar(null ==creditForm.getMortgageCar1() ? 0 :creditForm.getMortgageCar1());
		creditReport.setMortgageCarBalance(null ==creditForm.getMortgageCarBalance1() ? 0d :creditForm.getMortgageCarBalance1());
		creditReport.setAvgmonthRepayCar(null ==creditForm.getAvgmonthRepayCar1() ? 0d :creditForm.getAvgmonthRepayCar1());
		creditReport.setCreditPaymentBalance(null ==creditForm.getCreditPaymentBalance1() ? 0d :creditForm.getCreditPaymentBalance1());
		creditReport.setPledgePaymentBalance(null ==creditForm.getPledgePaymentBalance1() ? 0d :creditForm.getPledgePaymentBalance1() );
		creditReport.setImpawnPaymentBalance(null ==creditForm.getImpawnPaymentBalance1() ? 0d :creditForm.getImpawnPaymentBalance1());
		creditReport.setGroupAssureBalance(null ==creditForm.getGroupAssureBalance1() ? 0d :creditForm.getGroupAssureBalance1());
		creditReport.setCreditCount(null ==creditForm.getCreditCount1() ? 0 :creditForm.getCreditCount1());
		creditReport.setCreditBalance(null ==creditForm.getCreditBalance1() ? 0d :creditForm.getCreditBalance1());
		creditReport.setCreditLimitRate(null ==creditForm.getCreditLimitRate1() ? 0d :creditForm.getCreditLimitRate1());
		creditReport.setOutAssureCount(null ==creditForm.getOutAssureCount1() ? 0 :creditForm.getOutAssureCount1());
		creditReport.setCreditSearch(null ==creditForm.getCreditSearch1() ? 0 :creditForm.getCreditSearch1());
		creditReport.setPaymentStatus(creditForm.getPaymentStatus1());
		creditReport.setCreditStatus(creditForm.getCreditStatus1());
		creditReport.setCourtEnforcementStatus(creditForm.getCourtEnforcementStatus1());
		creditReport.setPaymentOverdueStatus(creditForm.getPaymentOverdueStatus1());
		creditReport.setCreditOverdueStatus(creditForm.getCreditOverdueStatus1());
		creditReport.setPaymentYearStatus(creditForm.getPaymentYearStatus1());
		creditReport.setNonbankPaymentBalance(null ==creditForm.getNonbankPaymentBalance1() ? 0d :creditForm.getNonbankPaymentBalance1());
		creditReport.setRemark(creditForm.getRemark1());
		creditReport.setBankBalanceOverdue(null==creditForm.getBankBalanceOverdue1()?0d:creditForm.getBankBalanceOverdue1());
		creditReport.setNonbankBalanceOverdue(null==creditForm.getNonbankBalanceOverdue1()?0d:creditForm.getNonbankBalanceOverdue1());
		creditReport.setOutAssureBalanceOverdue(null==creditForm.getOutAssureBalanceOverdue1()?0d:creditForm.getOutAssureBalanceOverdue1());
		creditReport.setCreditLimitOverdue(null==creditForm.getCreditLimitOverdue1()?0d:creditForm.getCreditLimitOverdue1());
		creditReport.setSixOverBalance(null ==creditForm.getSixOverBalance1() ? 0d:creditForm.getSixOverBalance1());
		creditReport.setTwentyFourOverdueCount(null==creditForm.getTwentyFourOverdueCount1()? 0:creditForm.getTwentyFourOverdueCount1());
		creditReport.setTwentyFourOverdueCreditCount(null==creditForm.getTwentyFourOverdueCreditCount1()? 0:creditForm.getTwentyFourOverdueCreditCount1());
		creditReport.setTwentyFourOverdueTopCount(null==creditForm.getTwentyFourOverdueTopCount1()? 0:creditForm.getTwentyFourOverdueTopCount1());
		creditReport.setTwentyFourOverdueCreditTopCount(null==creditForm.getTwentyFourOverdueCreditTopCount1()? 0:creditForm.getTwentyFourOverdueCreditTopCount1());
		// 银行贷款总额
		Double bankPaymentBalance = (null == creditForm.getMortgageCarBalance1() ? 0d
				: creditForm.getMortgageCarBalance1())
				+ (null == creditForm.getMortgageHouseBalance1() ? 0d : creditForm.getMortgageHouseBalance1())
				+ (null == creditForm.getPledgePaymentBalance1() ? 0d : creditForm.getPledgePaymentBalance1())
				+ (null == creditForm.getImpawnPaymentBalance1() ? 0d : creditForm.getImpawnPaymentBalance1())
				+ (null == creditForm.getGroupAssureBalance1() ? 0d : creditForm.getGroupAssureBalance1())
				+ (null == creditForm.getCreditPaymentBalance1() ? 0d : creditForm.getCreditPaymentBalance1());
		// 对外担保总余额
		creditReport.setOutAssureBalance(null==creditForm.getAssureBalance1()?0d:creditForm.getAssureBalance1());
		Double paymentBalance = bankPaymentBalance
				+ (null == creditForm.getNonbankPaymentBalance1() ? 0d : creditForm.getNonbankPaymentBalance1())
				+ (null == creditForm.getCreditLimitRate1() ? 0d : creditForm.getCreditLimitRate1());
		creditReport.setPaymentBalance(paymentBalance  + (null ==creditForm.getAssureBalance1() ? 0d :creditForm.getAssureBalance1()/2));//贷款余额需要加上担保余额的50%， 工单：loan-12621);
		creditReport.setBankPaymentBalance(bankPaymentBalance);
		creditReport.setLoanapplyNo(creditForm.getLoanapplyNo());
		creditReport.setCreateTime(date);
		creditReport.setUpdateTime(date);
		creditReport.setContractTotalOverdue(creditReport.getCreditLimitOverdue()+creditReport.getNonbankBalanceOverdue()+creditReport.getBankBalanceOverdue());
		creditReport.setFlag(StatusContexts.O2O_YES);
	}

	/**
	 * 配偶修改转换实体 方法
	 * 
	 * @param report
	 * @param creditForm
	 */
	public final static void CreditFromTransToCredit(CreditReport report, CreditForm creditForm) {
		report.setAssureBalance(null ==creditForm.getAssureBalance1() ? 0d :creditForm.getAssureBalance1());
		report.setAssureStatus(creditForm.getAssureStatus1());
		report.setAssureTotal(null ==creditForm.getAssureTotal1() ? 0d :creditForm.getAssureTotal1());
		report.setAvgCardusedAmt(null ==creditForm.getAvgCardusedAmt1() ? 0d :creditForm.getAvgCardusedAmt1() );
		report.setContractTotal(null ==creditForm.getContractTotal1() ? 0d :creditForm.getContractTotal1());
		report.setContractTotalOverdue(null ==creditForm.getContractTotalOverdue1() ? 0d :creditForm.getContractTotalOverdue1());
		report.setMortgageHouse(null ==creditForm.getMortgageHouse1() ? 0 :creditForm.getMortgageHouse1());
		report.setMortgageHouseBalance(null ==creditForm.getMortgageHouseBalance1() ? 0d :creditForm.getMortgageHouseBalance1());
		report.setAvgmonthRepayHouse(null ==creditForm.getAvgmonthRepayHouse1() ? 0d :creditForm.getAvgmonthRepayHouse1());
		report.setMortgageCar(null ==creditForm.getMortgageCar1() ? 0 :creditForm.getMortgageCar1());
		report.setMortgageCarBalance(null ==creditForm.getMortgageCarBalance1() ? 0d :creditForm.getMortgageCarBalance1());
		report.setAvgmonthRepayCar(null ==creditForm.getAvgmonthRepayCar1() ? 0d :creditForm.getAvgmonthRepayCar1());
		report.setCreditPaymentBalance(null ==creditForm.getCreditPaymentBalance1() ? 0d :creditForm.getCreditPaymentBalance1());
		report.setPledgePaymentBalance(null ==creditForm.getPledgePaymentBalance1() ? 0d :creditForm.getPledgePaymentBalance1() );
		report.setImpawnPaymentBalance(null ==creditForm.getImpawnPaymentBalance1() ? 0d :creditForm.getImpawnPaymentBalance1());
		report.setGroupAssureBalance(null ==creditForm.getGroupAssureBalance1() ? 0d :creditForm.getGroupAssureBalance1());
		report.setCreditCount(null ==creditForm.getCreditCount1() ? 0 :creditForm.getCreditCount1());
		report.setCreditBalance(null ==creditForm.getCreditBalance1() ? 0d :creditForm.getCreditBalance1());
		report.setCreditLimitRate(null ==creditForm.getCreditLimitRate1() ? 0d :creditForm.getCreditLimitRate1());
		report.setOutAssureCount(null ==creditForm.getOutAssureCount1() ? 0 :creditForm.getOutAssureCount1());
		report.setCreditSearch(null ==creditForm.getCreditSearch1() ? 0 :creditForm.getCreditSearch1());
		report.setPaymentStatus(creditForm.getPaymentStatus1());
		report.setCreditStatus(creditForm.getCreditStatus1());
		report.setCourtEnforcementStatus(creditForm.getCourtEnforcementStatus1());
		report.setPaymentOverdueStatus(creditForm.getPaymentOverdueStatus1());
		report.setCreditOverdueStatus(creditForm.getCreditOverdueStatus1());
		report.setPaymentYearStatus(creditForm.getPaymentYearStatus1());
		report.setNonbankPaymentBalance(null ==creditForm.getNonbankPaymentBalance1() ? 0d :creditForm.getNonbankPaymentBalance1());
		report.setRemark(creditForm.getRemark1());
		report.setBankBalanceOverdue(null==creditForm.getBankBalanceOverdue1()?0d:creditForm.getBankBalanceOverdue1());
		report.setNonbankBalanceOverdue(null==creditForm.getNonbankBalanceOverdue1()?0d:creditForm.getNonbankBalanceOverdue1());
		report.setOutAssureBalanceOverdue(null==creditForm.getOutAssureBalanceOverdue1()?0d:creditForm.getOutAssureBalanceOverdue1());
		report.setCreditLimitOverdue(null==creditForm.getCreditLimitOverdue1()?0d:creditForm.getCreditLimitOverdue1());
		report.setSixOverBalance(null ==creditForm.getSixOverBalance1() ? 0d:creditForm.getSixOverBalance1());
		report.setTwentyFourOverdueCount(null==creditForm.getTwentyFourOverdueCount1()? 0:creditForm.getTwentyFourOverdueCount1());
		report.setTwentyFourOverdueCreditCount(null==creditForm.getTwentyFourOverdueCreditCount1()? 0:creditForm.getTwentyFourOverdueCreditCount1());
		report.setTwentyFourOverdueTopCount(null==creditForm.getTwentyFourOverdueTopCount1()? 0:creditForm.getTwentyFourOverdueTopCount1());
		report.setTwentyFourOverdueCreditTopCount(null==creditForm.getTwentyFourOverdueCreditTopCount1()? 0:creditForm.getTwentyFourOverdueCreditTopCount1());
		// 银行贷款总额
		Double bankPaymentBalance = (null == creditForm.getMortgageCarBalance1() ? 0d
				: creditForm.getMortgageCarBalance1())
				+ (null == creditForm.getMortgageHouseBalance1() ? 0d : creditForm.getMortgageHouseBalance1())
				+ (null == creditForm.getPledgePaymentBalance1() ? 0d : creditForm.getPledgePaymentBalance1())
				+ (null == creditForm.getImpawnPaymentBalance1() ? 0d : creditForm.getImpawnPaymentBalance1())
				+ (null == creditForm.getGroupAssureBalance1() ? 0d : creditForm.getGroupAssureBalance1())
				+ (null == creditForm.getCreditPaymentBalance1() ? 0d : creditForm.getCreditPaymentBalance1());
		// 对外担保总余额
		report.setOutAssureBalance(null==creditForm.getAssureBalance1()?0d:creditForm.getAssureBalance1());
		Double paymentBalance = bankPaymentBalance
				+ (null == creditForm.getNonbankPaymentBalance1() ? 0d : creditForm.getNonbankPaymentBalance1())
				+ (null == creditForm.getCreditLimitRate1() ? 0d : creditForm.getCreditLimitRate1());
		report.setPaymentBalance(paymentBalance);
		report.setBankPaymentBalance(bankPaymentBalance);
		report.setContractTotalOverdue(report.getCreditLimitOverdue()+report.getNonbankBalanceOverdue()+report.getBankBalanceOverdue());

	}
}
